<?php

require_once("Exercises/Model/MuscleGroup.php");
require_once("Exercises/Model/ExerciseName.php");
require_once("Exercises/Model/ExerciseDescription.php");

class Exercise
{
	/**
    *@var int
    **/
	private $id;
	/**
    *@var int
    **/
	private $userId;
	/**
    *@var int
    **/
	private $reps;
	/**
    *@var int
    **/
	private $sets;
	/**
	*@var string
	**/
	private $youtubeLink;
	/**
    *@var int
    **/
	private $orderNumber;
	/**
    *@var MuscleGroup
    **/
	private $muscleGroup;
	/**
    *@var ExerciseName
    **/
	private $exerciseName;
	/**
    *@var ExerciseDescription
    **/
	private $exerciseDescription;



	/**
    *@param MuscleGroup
    *@param ExerciseName
    *@param ExerciseDescription
    *@param string
    *@param int
    *@param int
    *@param int
    *@param int
    *@param int
    **/
	private function __construct(MuscleGroup $muscleGroup,  ExerciseName $exerciseName, ExerciseDescription $exerciseDescription, 
						         $youtubeLink ="", $userId,  $id = null,$set = null, $reps = null, $orderNumber = null)
	{
		$this->muscleGroup = $muscleGroup;
		$this->exerciseName = $exerciseName;
		$this->exerciseDescription = $exerciseDescription;
		$this->youtubeLink = $youtubeLink; 
		$this->userId = $userId;
		if($set != null)
		{
			$this->sets = $set; 
		}
		if($reps != null)
		{
			$this->reps = $reps;
		}
		if($orderNumber != null)
		{
			$this->orderNumber = $orderNumber;
		}			
		if($id != null)
		{
			$this->id = $id;
		}
	}

	/**
    *@param string
    *@param int
    *@param string
    *@param string
    *@param string
    *@param int
    *@return Exercise
    **/
	public static function createNewExercise($muscleGroup, $muscleGroupID, $exerciseName, $exerciseDescription,$youtubeLink, $userId = null)
	{
		return new Exercise(new MuscleGroup($muscleGroupID, $muscleGroup), 
			                new ExerciseName($exerciseName), 
			                new ExerciseDescription($exerciseDescription),
			                $youtubeLink, $userId);
	}

	/**
    *@param string
    *@param int
    *@param string
    *@param string
    *@param string
    *@param int
    *@param int
    *@param int array
    *@param int array
    *@param int array
    *@return Exercise
    **/
	public static function createWorkoutExerciseFromDatabase($muscleGroup,$muscleGroupID, $exerciseName, $exerciseDescription, 
															 $youtubeLink, $userId, $id, $set, $reps, $orderNumber)
	{
		return new Exercise(new MuscleGroup($muscleGroupID, $muscleGroup), 
			                new ExerciseName($exerciseName), 
			                new ExerciseDescription($exerciseDescription),  
			                $youtubeLink, $userId, $id, $set, $reps, $orderNumber);
	}


	/**
    *@param string
    *@param int
    *@param string
    *@param string
    *@param string
    *@param int
    *@param int
    *@return Exercise
    **/
	public static function createNewExerciseFromDatabase($muscleGroup,$muscleGroupID, $exerciseName, $exerciseDescription, $youtubeLink, $userId, $id)
	{
		return new Exercise(new MuscleGroup($muscleGroupID, $muscleGroup), 
			                new ExerciseName($exerciseName), 
			                new ExerciseDescription($exerciseDescription),  
			                $youtubeLink, $userId, $id);
	}

	/**
    *@return int
    **/
	public function getExerciseID()
	{
		return $this->id;
	}

	/**
    *@return int
    **/
	public function getUserID()
	{
		return $this->userId;
	}

	/**
    *@return int
    **/
	public function getSets()
	{
		return $this->sets;
	}

	/**
    *@return int
    **/
	public function getReps()
	{
		return $this->reps;
	}

	/**
    *@return int
    **/
	public function getOrderNumber()
	{
		return $this->orderNumber;
	}


	/**
    *@return string
    **/
	public function getYoutubeLink()
	{
		return $this->youtubeLink;
	}

	/**
    *@return string
    **/
	public function getExerciseName()
	{
		return $this->exerciseName->getExerciseName();
	}

	/**
    *@return string
    **/
	public function getMusclegroup()
	{
		return $this->muscleGroup->getMusclegroup();
	}

	/**
    *@return int
    **/
	public function getMusclegroupID()
	{
		return $this->muscleGroup->getMuscleGroupID();
	}

	/**
    *@return string
    **/
	public function getExerciseDescription()
	{
		return $this->exerciseDescription->getExerciseDescription();
	}

	/**
	*@param int
    *@return boolean
    **/
	public function CheckIfSameID($otherID)
	{
		if($otherID == $this->getUserID()) 
		{								   
			return true;
		}
		return false;
	}

}